﻿using System;
using System.Collections;
namespace CardLib
{
	public class Cards:CollectionBase, ICloneable
	{
		public void Add(Card card)
		{
			List.Add(card);
		}

		public void remove(Card card)
		{
			List.Remove(card);
		}

		public Card this[int index]
		{
			get
			{
				return (Card)List[index];
			}
			set
			{
				List[index] = value;
			}
		}

		public void CopyTo(Cards newCards)
		{
			for (int i = 0; i < List.Count; i++)
			{
				newCards[i] = this[i];
				//也可以用this，但是需要强制转换
				// newCards[i] = (Card)List[i];
			}
		}

		public bool Contains(Card card)
		{
			return List.Contains(card);
		}

		public object Clone()
		{	
			Cards newCards = new Cards();
			foreach (Card card in InnerList)
			{
				newCards.Add((Card)card.Clone());
			}

			return newCards;
		}
	}
}